package com.foreknow.mapping;

import java.util.HashMap;
import java.util.Map;

public class MappingFactory {
    private UserMapping user;
    private GuestbookMapping gb;
    //创建一个Map容器用来保存xxxmapping
    private Map<String,EntityMapping> mse = new HashMap<>();
    private static MappingFactory mf = null;
    public static final String USER_MAPPING = "userMapping";
    public static final String GUESTBOOK_MAPPING = "guestbookmapping";

    public MappingFactory(){

    }
    public static MappingFactory getmf(){
        if (mf==null){
            mf = new MappingFactory();
        }
        mf.mse.put(USER_MAPPING,new UserMapping());
        mf.mse.put(GUESTBOOK_MAPPING,new GuestbookMapping());
        return mf;
    }
//    public static MappingFactory getmfgb(){
//        if (mf==null){
//            mf = new MappingFactory();
//        }
//        mf.mse.put(GUESTBOOK_MAPPING,new GuestbookMapping());
//        return mf;
//    }

    public EntityMapping getmapping(String key){
        return mse.get(key);
    }

    public UserMapping getUser() {
        return user;
    }

    public void setUser(UserMapping user) {
        this.user = user;
    }

    public GuestbookMapping getGb() {
        return gb;
    }

    public void setGb(GuestbookMapping gb) {
        this.gb = gb;
    }
}
